

//
//  HYNavigationController.swift
//  WeiBo
//
//  Created by crazyfish on 16/3/11.
//  Copyright © 2016年 crazyfish. All rights reserved.
//

import UIKit

class HYNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        
        //只在判断里面的子控制器的数量大于0,
        
        if childViewControllers.count > 0{
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageNamed: "navigationbar_pop-1",title: self.title, target: self, action: "back")
        
            
        }else if childViewControllers.count > 1{
            
              viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageNamed: "navigationbar_pop-1",title: "返回", target: self, action: "back")
            
        }
        
        
        super.pushViewController(viewController, animated:true)
        
    }

   
    func back(){
        
        //本身就是nav
     popViewControllerAnimated(true)
        
    }
}

